package com.biomatch.utils;

import java.util.Date;
import java.util.Random;

public class CommonUtils {

    public static String getRamdonStr(){
        Date currentDate = new Date();
        String dateStr = DateUtils.getDateString(currentDate, "yyyyMMddHHmmss");
        String randomStr = CommonUtils.getRandom4Bit();
        dateStr = dateStr + randomStr;
        return dateStr;
    }

    public static String getRandom4Bit() {
        Random rand = new Random();
        Integer randomInt = rand.nextInt(9999);
        String randomStr = randomInt.toString();
        if (randomStr.length() == 1) {
            randomStr = "000" + randomStr;
        } else if (randomStr.length() == 2) {
            randomStr = "00" + randomStr;
        } else if (randomStr.length() == 3) {
            randomStr = "0" + randomStr;
        }
        return randomStr;
    }
}
